package com.erp.order.purchasing.dao.impl;

import com.erp.hr.base.dao.impl.BaseDaoImpl;
import com.erp.order.purchasing.dao.QuotedPriceDetailDao;
import com.erp.order.purchasing.model.QuotedPriceDetail;
import org.redragon.framework.hibernate.DaoSupport;
import org.redragon.framework.hibernate.model.Pages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
@Repository
public class QuotedPriceDetailDaoImpl extends BaseDaoImpl<QuotedPriceDetail> implements QuotedPriceDetailDao {
    /**
     * dao支持
     */
    @Autowired
    private DaoSupport daoSupport;

    @Override
    public QuotedPriceDetail getDataObject(String s) {
        return null;
    }

    /**
     * 根据条件查询对象集合
     * @param quotedPriceDetail 报价详情对象
     * @return 对象集合
     */
    @Override
    public List<QuotedPriceDetail> getDataObjects(QuotedPriceDetail quotedPriceDetail) {
        return daoSupport.selectDataSql(
                "SELECT " +
                    "qpd.* " +
                "FROM " +
                    "quoted_price_detail qpd " +
                "WHERE " +
                    "qpd.inquiry_list_id = :ili " +
                "AND " +
                    "qpd.supplier_id IN (:sid)",
                new HashMap<String, Class<?>>(){{
                    put("qpd", QuotedPriceDetail.class);
                }},
                new HashMap<String, Object>(){{
                    put("ili", quotedPriceDetail.getInquiryListId());
                    put("sid", quotedPriceDetail.getIds());
                }});
    }

    @Override
    public List<QuotedPriceDetail> getDataObjectsForDataAuth(String s, Pages pages, QuotedPriceDetail quotedPriceDetail) {
        return null;
    }

    @Override
    public void saveDataObject(QuotedPriceDetail quotedPriceDetail) {
        this.daoSupport.insertDataTransaction(quotedPriceDetail);

    }
}
